package com.zzq.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.zzq.domain.entity.SmilePhotographerDividend;
import com.zzq.enumerate.DividendTypeEnum;
import com.zzq.mapper.SmilePhotographerDividendMapper;
import com.zzq.mapper.SmilePhotographerDividendRuleMapper;
import com.zzq.service.SmilePhotographerDividendService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzq.util.ObjectUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author 小布
 * @since 2023-10-07
 */
@Service
public class SmilePhotographerDividendServiceImpl extends ServiceImpl<SmilePhotographerDividendMapper, SmilePhotographerDividend> implements SmilePhotographerDividendService {

    @Autowired
    SmilePhotographerDividendMapper photographerDividendMapper;

    @Override
    public Boolean isEmptyDividend(Long photographerId,String tyep, Boolean lock) {
        LambdaQueryWrapper<SmilePhotographerDividend> queryWrapper=new LambdaQueryWrapper();
        queryWrapper.eq(SmilePhotographerDividend::getPhotographerId,photographerId);
        queryWrapper.eq(SmilePhotographerDividend::getPhotographerDividendType,tyep);
        queryWrapper.eq(!ObjectUtils.isEmpty(lock),SmilePhotographerDividend::getPhotographerDividendProportionLock,lock);
        Integer i = photographerDividendMapper.selectCount(queryWrapper);
        if (i>0){
            return true;
        }else {
            return false;
        }
    }

    @Override
    public Boolean isEmptyDividend(Long photographerId, String tyep) {

        return isEmptyDividend(photographerId,tyep,null);
    }

    @Override
    public SmilePhotographerDividend getShootDividendRule(Long photographerId) {
        LambdaQueryWrapper<SmilePhotographerDividend> queryWrapper=new LambdaQueryWrapper();
        queryWrapper.eq(SmilePhotographerDividend::getPhotographerId,photographerId);
        queryWrapper.eq(SmilePhotographerDividend::getPhotographerDividendType, DividendTypeEnum.SHOOT_DIVIDEND);
        queryWrapper.eq(SmilePhotographerDividend::getPhotographerDividendProportionLock,true);
        return   photographerDividendMapper.selectOne(queryWrapper);
    }
}
